module.exports = {
	$(selector) {
		let nodeList = document.querySelectorAll(selector);
		// switch(nodeList.length){
		//     case:0

		// }
		if (nodeList.length === 0) {
			return console.warn(`${selector} 节点没有获取到 `);
		}
		if (nodeList.length === 1) {
			return nodeList[0];
		}
		if (nodeList.length > 1) {
			return nodeList;
		}
	},
	// 封装跳转函数
	turnToPage(page, selector) {
		document.querySelector(selector).addEventListener("click", function () {
			window.location.href = `${page}.html`;
		});
	},

	navBo(filename) {
		let html = `  
    <a href="index.html" class="${filename === "index" ? "active" : ""}">
      <span class="iconfont icon-shouye"></span>
      <p>首页</p>
    </a>
    <a href="sport.html" class="${filename === "sport" ? "active" : ""}">
      <span class="iconfont 24gl-heartPulse icon-24gl-heartPulse"></span>
      <p>运动</p>
    </a>

    <a href="mine.html" class="${filename === "mine" ? "active" : ""}">
      <span class="iconfont icon-wode"></span>
      <p>我的</p>
    </a>`;
		this.$(".index-fix").innerHTML = html;
	},

	// 封装跳转函数
	turnToPage(page, selector) {
		document.querySelector(selector).addEventListener("click", function () {
			window.location.href = `${page}.html`;
		});
	},
	//封装渲染底部导航函数
	//page需要激活样式到页面
	renderNavtaber(page) {
		// 拼接
		let html = `
    <p class="flex1 dpflex ${page === "index" ? "active" : ""}">
        <span class="iconfont icon-index"></span> Index
    </p>
 
    <p class="flex1 dpflex ${page === "sports" ? "active" : ""}">
        <span class="iconfont icon-sports2"></span>
        Sports
    </p>

    <p class="flex1 dpflex ${page === "mine" ? "active" : ""}">
        <span class="iconfont icon-mine"></span>
        Mine
    </p>`;
		// 渲染
		this.$("footer").innerHTML = html;
	},
};
